package org.jie.guider.framework.mybatis;

import java.io.IOException;
import java.io.InputStream;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.jie.guider.framework.mybatis.mapper.UserMapper;

/**
 * @author LiJie
 */
public class MybatisApplication {

    public static void main(String[] args) {
        String configFile = "mybatis-config.xml";
        InputStream is = null;
        try {
            is = Resources.getResourceAsStream(configFile);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
        try (SqlSession session = sessionFactory.openSession()) {
            UserMapper userMapper = session.getMapper(UserMapper.class);
            userMapper.selectOne(1);
//            Map<Object, Object> user = session.selectOne
//                ("org.jie.guider.framework.mybatis.mapper.UserMapper.selectOne", 1);
        }
    }
}
